﻿@using UserStories.Models
@using UserStories.ViewModels.Projects

@model IndexViewModel

@{
    ViewBag.Title = "Projects";
    var user = ViewBag.User as User;
}

<h2>Projects</h2>

<table>
    <tr>
        <th>Name</th>
        <th>Description</th>
        <th>Role</th>
        <th>Actions</th>
    </tr>
    @foreach (var project in Model.Projects)                                          
    {
        <tr>
            <td>@project.Name</td>
            <td>@project.Description</td>
            <td>@project.Role</td>
            <td>@Html.ActionLink("Edit", "Edit", new { id = project.Id })</td>
        </tr>
    }
</table>

@if(user != null && user.IsSysAdmin)
{
    <div>
        @Html.ActionLink("Create new project", "Edit", new {id = 0})
    </div>               
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           